import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'index',
    component: () => import('../views/front/IndexView.vue')
  },
  {
    path: '/detail',
    name: 'detail',
    component: () => import('../views/front/BookDetail.vue')
  },
  {
    path: '/read',
    name: 'read',
    component: () => import('../views/front/ReadView.vue')
  },
  {
    path: '/category',
    name: 'category',
    component: () => import('../views/front/CategoryView.vue')
  },
  {
    path: '/record',
    name: 'record',
    component: () => import('../views/front/RecordView.vue')
  },
  {
    path: '/user',
    name: 'user',
    component: () => import('../views/front/UserCenter.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/admin/LoginView.vue')
  }, {
    path: '/home',
    name: 'home',
    redirect: '/home/about',
    component: () => import('../views/admin/HomeView.vue'),
    children: [
      {
        path: 'about', /* 子路由path前不允许有斜线 */
        name: 'about',
        component: () => import('../views/admin/AboutView.vue')
      },
      {
        path: 'notice',
        name: 'notice',
        component: () => import('../views/admin/notice/NoticeList.vue')
      },
      {
        path: 'userinfo',
        name: 'userinfo',
        component: () => import('../views/admin/userinfo/UserinfoList.vue')
      },
      {
        path: 'feedback',
        name: 'feedback',
        component: () => import('../views/admin/feedback/FeedbackList.vue')
      },
      {
        path: 'ad',
        name: 'ad',
        component: () => import('../views/admin/ad/AdList.vue')
      },
      {
        path: 'category',
        name: 'category',
        component: () => import('../views/admin/category/CategoryList.vue')
      },
      {
        path: 'book',
        name: 'book',
        component: () => import('../views/admin/book/BookList.vue')
      },
      {
        path: 'catalog',
        name: 'catalog',
        component: () => import('../views/admin/catalog/CatalogList.vue')
      }
    ]
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
